The present invention relates to the field of computer programming, and more specifically, to a computer-implemented method, a system and a computer program product for code suggestion.
Today, many Integrated Development Environments (IDEs) have been developed to facilitate programming work of programmers, such as Visual Studio®, Eclipse®, JetBrains®, Jupyter Notebook® and etc. In many of these IDEs, a function referred to as code suggestion is provided to accelerate the input of codes. If a programmer types, in an editor of an IDE for Java language, a line of code “System.out.printl”, which has an incomplete name of method, a menu will pop up near the cursor in the editor, which shows names of methods starting with “printl”, such as “println( )”, “println(boolean x)”, “println(char x)”, “println(float x)” and etc. The programmer may choose one option from the menu to complement the incomplete name of method. For example, if the name of method “println(float x)” on the menu is chosen by the programmer, the code being edited will be automatically complemented as “System.out.println(float x)”.
In another example, if an incomplete variable “ttest_” is input by a programmer in an editor of an IDE, a menu will pop up near the cursor in the editor, which shows variable names starting with “ttest_”, such as “ttest_lsamp”, “ttest_ind”, “ttest_ind_from_stats” and etc. The programmer may choose one option from the menu to complement the incomplete variable. For example, if the variable name “ttest_ind” on the menu is chosen by the programmer, the incomplete variable will be automatically complemented as “ttest_ind” in full.
Additionally, the current IDEs can also provide code suggestion for keywords of a programming language. For example, in an editor for C language, if “siz” is input by a programmer, a code suggestion of “sizeof” will be presented to the programmer, which is a keyword of C language in its complete form. All of the above techniques are referred to as code suggestion, which help programmers to remind names of variables and methods, and keywords of programming languages and to input codes fast.